package com.vhall.component.plugin.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author jingwen.li
 */
@Getter
@AllArgsConstructor
public enum GoodsOfTypeEnum {
    DEFAULT(0, ""),
    OF_TYPE_1(1, "股票型"),
    OF_TYPE_2(2, "混合型"),
    OF_TYPE_3(3, "债券型"),
    OF_TYPE_4(4, "货币型"),
    OF_TYPE_6(6, "QDII"),
    OF_TYPE_7(7, "其他");

    private final Integer type;
    private final String name;

    public static String getName(Integer type) {
        GoodsOfTypeEnum parse = parse(type);
        if (parse != null) {
            return parse.getName();
        }
        return StringUtils.EMPTY;
    }

    public static GoodsOfTypeEnum parse(Integer type) {
        for (GoodsOfTypeEnum anEnum : GoodsOfTypeEnum.values()) {
            if (anEnum.getType().equals(type)) {
                return anEnum;
            }
        }
        return DEFAULT;
    }
}
